python program to calculate profit and loss